$(function () {
  const baseURL = 'http://localhost:8080/api/v1'
  //搜索按钮点击事件
  $('.search_btn').click(function () {
    //获取搜索内容
    var text = $('.search_txt').val();
    //ajax请求
    $.ajax({
      method: 'get',
      url: baseURL + '/index/search',
      data: {
        key: text,
        type: '',
        page: 1,
        perpage: 6,
      },
      success: function (res) {
        console.log(res);
        $('.setfr').html(template('news', res));
      }
    })

  });

  //页面一加载：默认搜索全部
  $('.search_btn').trigger('click');
});